package cn.wolfcode.rbac.web.controller;

import cn.wolfcode.rbac.service.ILoginService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

/**
 * Created by Administrator on 2020/7/13 0013.
 */
@Controller
public class LoginController {
    @Autowired
    private ILoginService loginService;
    @RequestMapping("/login")
    public String login(Model model,String username, String password){
        try{
            loginService.login(username,password);
            return "redirect:/department/list.do";
        }catch (Exception e){
            e.printStackTrace();
            model.addAttribute("errorMsg",e.getMessage());
            return "forward:/login.jsp";
        }
    }
}
